<?php
    class menu_add_controller extends controllerBase
    {
        public function process()
        {
            if(isset($_POST['val']))
            {
                if(empty($_POST['val']['title']))
                {
                    return $this->url->getLink('admin/menu/add',true, 'Title can not be null.');
                }
                if($this->database->add('menus',$_POST['val']))
                {
                    return $this->url->getLink('admin/menu/add', true, 'Add new category successful.');
                }
                else
                {
                    return $this->url->getLink('admin/menu/add', true, 'Can not add category.');
                }
            }
            $aResults = $this->database->getListObject('SELECT * FROM menus');
            $this->set(array('aMenus' => $aResults));
        }
    }
?>
